﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SCResources.General;


namespace UnitTests
{
    /// <summary>
    /// Summary description for SerieCollectionUnitTests
    /// </summary>
    [TestClass]
    public class SerieCollectionUnitTests
    {
        public SerieCollectionUnitTests()
        {
            
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void removeSerieTest_RemoveSerieFromActiveSeries()
        {
            List<Serie> series = new List<Serie>();
            series.Add(new Serie("test",2,3,new DateTime(2011,5,5),0));

            SerieCollection serieCollection = new SerieCollection(series,series);

            Assert.AreEqual(true,serieCollection.removeSerie("test", SelectedCollection.Active));
            Assert.AreEqual(0, serieCollection.ActiveSeries.Count);
        }

        [TestMethod]
        public void removeSerieTest_RemoveSerieFromEmptyList()
        {
            List<Serie> series = new List<Serie>();
            series.Add(new Serie("test",2,3,new DateTime(2011,5,5),0));

            SerieCollection serieCollection = new SerieCollection(series, new List<Serie>());

            Assert.AreEqual(false,serieCollection.removeSerie("test",SelectedCollection.Archived));
        }

        [TestMethod]
        public void removeSerieTest_RemoveUnknownSerie()
        {
            List<Serie> series = new List<Serie>();
            series.Add(new Serie("test", 2, 3, new DateTime(2011, 5, 5), 0));

            SerieCollection serieCollection = new SerieCollection(series, series);

            Assert.AreEqual(false, serieCollection.removeSerie("mismatch", SelectedCollection.Active));
        }

        [TestMethod]
        public void updateSerieTest_UpdateActiveSerie()
        {
            List<Serie> series = new List<Serie>();
            series.Add(new Serie("test", 2, 3, new DateTime(2011, 5, 5), 0));
            series.Add(new Serie("appel", 2, 3, new DateTime(2011, 5, 5), 0));
            series.Add(new Serie("peren", 2, 3, new DateTime(2011, 5, 5), 0));

            SerieCollection serieCollection = new SerieCollection(series, series);

            Serie update = new Serie("update", 2, 3, new DateTime(2011, 5, 5), 0);
            serieCollection.updateSerie(update, "test", SelectedCollection.Active);

            Assert.AreEqual(update,serieCollection.ActiveSeries[0]);
        }

        [TestMethod]
        public void getAiredSeriesTest_GetAiredSeries()
        {
            List<Serie> series = new List<Serie>();
            series.Add(new Serie("test", 2, 3, new DateTime(2012,3,4), 0));
            series.Add(new Serie("appel", 2, 3, DateTime.Now, 0));
            series.Add(new Serie("peren", 2, 3, DateTime.Now, 0));

            SerieCollection serieCollection = new SerieCollection(series, series);

            List<Serie> returned = new List<Serie>();
            returned.Add(new Serie("appel", 2, 3, DateTime.Now, 0));
            returned.Add(new Serie("peren", 2, 3, DateTime.Now, 0));

            Assert.AreEqual(returned.Count,serieCollection.getAiredSeries(0).Count);
        }


    }
}
